package br.com.fiap.beans;

import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public abstract class AbstractBeanAcessor{
	
	public HttpServletRequest getRequest(){
		FacesContext context = FacesContext.getCurrentInstance();  
		HttpServletRequest request = (HttpServletRequest)context.getExternalContext().getRequest();  
		return request;
	}
	
	public HttpSession getSession(){
		return getRequest().getSession(); 
	}
	
	public void setRequest(String name, Object obj){
		FacesContext context = FacesContext.getCurrentInstance();  
		HttpServletRequest request = (HttpServletRequest)context.getExternalContext().getRequest();  
		request.setAttribute(name, obj);
	}
	
	public void setSession(String name, Object obj){
		getRequest().getSession().setAttribute(name, obj);
	}	
}
